package current.security.init;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import current.security.dao.ISecurityDao;
import current.security.user.domain.Resc;
/**
 * <p>Title: an SecurityManagerSupport.java file of the axtPortal project. </p>
 * <p>Description: </p>
 * <p>Create Time: 2009-11-6 ����02:50:34 </p>
 * <p>Company: Guangzhou Xindun Network Tech Co., Ltd</p>
 * @author Zhantao Feng
 * @version 1.0
 */
public abstract class DefaultSecurityServiceImpl implements SecurityService {
    @Resource
	ISecurityDao securityDao ;
//	private Logger log = Logger.getLogger(SecurityServiceImpl.class);
    @Override
    public Map<String, String> loadRescByType(String type) throws Exception{
        Map<String, String> urlAuthorities = new LinkedHashMap<String, String>();
        
        List<Resc> urlResources = securityDao.loadRescByType(type);
        for(Resc resource : urlResources) {
            urlAuthorities.put(resource.getString(), resource.getRoleAuthorities());
        }
        return urlAuthorities;
    }
  
    @Override
	public Map<String, String> queryAllMap()
			throws Exception {
    	  Map<String, String> urlAuthorities = new LinkedHashMap<String, String>();
    	  List<Resc> urlResources = securityDao.queryAll();
          for(Object resource : urlResources) {
              urlAuthorities.put(((Resc)resource).getString(), ((Resc)resource).getRoleAuthorities());
          }
          return urlAuthorities;
	}

	/**
	 * @return the securityDao
	 */
	public ISecurityDao getSecurityDao() {
		return securityDao;
	}

	/**
	 * @param securityDao the securityDao to set
	 */
	public void setSecurityDao(ISecurityDao securityDao) {
		this.securityDao = securityDao;
	}

}
